package com.wxzhou.wangzhuan.entity;

/**
 * 广告发生时机
 */
public enum AdBusinessAction {
    PRE(0, "预请求"),
    SUCCESS_SHOW(1, "成功展示"),
    ERROR(2, "错误"),
    SUCCESS(3, "成功回调"),
    SUCCESS_CLOSE(4, "正常关闭"),
    CLICK_AD(5, "点击广告");

    private final int code;
    private final String description;

    AdBusinessAction(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static AdBusinessAction fromCode(int code) {
        for (AdBusinessAction status : values()) {
            if (status.code == code) {
                return status;
            }
        }
        throw new IllegalArgumentException("Unknown ad sense code: " + code);
    }

}
